package com.jiayou

import com.jiayou.server.ImServer
import org.mybatis.spring.annotation.MapperScan
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.SpringApplicationRunListener
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.context.event.ApplicationReadyEvent
import org.springframework.boot.runApplication
import org.springframework.context.ApplicationListener
import org.springframework.context.ConfigurableApplicationContext
import org.springframework.context.annotation.ComponentScan
import org.springframework.scheduling.annotation.EnableAsync

/**
@author 李 双
@data   2020-11-19  11:16
@info
 */


@EnableAsync
@MapperScan("com.jiayou.im")
@SpringBootApplication(scanBasePackages = ["com.jiayou"])
open class NettyApplication : ApplicationListener<ApplicationReadyEvent> {
    @Autowired
    private lateinit var imServer: ImServer
    override fun onApplicationEvent(p0: ApplicationReadyEvent) {
        try {
            imServer.startServer()
        } catch (e: Exception) {
            println("未知异常 ${e.printStackTrace()}")
        }
    }
}

fun main(args: Array<String>) {
    runApplication<NettyApplication>(*args)
}